#pragma once
#include "bitset.h"
#include <bitset>
#include <string>

namespace BLZ
{
    template <size_t K, size_t M, size_t N>
    class BloomFilter
    {
    private:
         BLZ::bitset<M> _bs;
         //std::bitset<M>* _bs;
    public:
        //BloomFilter() : _bs(new std::bitset<M>) {}
        //~BloomFilter()
        //{
        //    delete _bs;
        //}

        size_t HashFunc(size_t seed, std::string& str)
        {
            std::hash<std::string> hasher;
            size_t base_hash = hasher(str);

            return base_hash ^ (seed * 0x9e3779b9 + (seed << 6) + (seed >> 2));
        }

        void set(std::string str)
        {
            int i = 0;
            for (i = 1; i <= K; i++)
            {
                //_bs->set(HashFunc(i, str) % M);
                _bs.set(HashFunc(i, str) % M);
            }
        }
        bool test(std::string str)
        {
            int i = 0;
            for (i = 1; i <= K; i++)
            {
                //if (!_bs->test(HashFunc(i, str) % M))
                if (!_bs.test(HashFunc(i, str) % M))
                {
                    return false;
                }
            }
            return true;
        }
    };
}